﻿@using FCTC_Web.Utilities
@using DAL
@using FCTC_Web.Models
@model FCTC_Web.Models.SessionArrangement
@*@{
    ViewBag.Title = "商家";
}*@
@Combres.HtmlExtensions.CombresLink("backjs")
<script type="text/javascript">
    $(document).ready(function () {
        $('#StartTime').timepicker({
            ampm: true,
            hourMin: 8,
            hourMax: 18
        });

        $('#EndTime').timepicker({
            ampm: true,
            hourMin: 8,
            hourMax: 18
        });

        $('#Day').datepicker(
            { showMonthAfterYear: true,
                showOn: 'both',
                buttonImage: '/images/calendar.png',
                buttonImageOnly: true,
                dateFormat: 'yy-m-d '
            }, $.datepicker.regional['cn']);

        $(".selectable").selectable();

        $("#divLeftTeam").dialog({
            autoOpen: false,
            show: "drop",
            hide: "drop",
            height: 500,
            width: 470,
            modal: true,
            buttons: {
                "确定": function () {
                    var $this = $(this);
                    var target = $this.find('#teamTarget');
                    var id = target.find("li").attr('dataid');
                    var datavalue = target.find("li").attr('datavalue');
                    $("#LeftTeamID").val(id);
                    $("#leftTeamName").val(datavalue);
                    $this.dialog("close");

                },
                "取消": function () {
                    $(this).dialog("close");
                }
            },
            close: function () {
            }
        });

        $("#divRightTeam").dialog({
            autoOpen: false,
            show: "drop",
            hide: "drop",
            height: 500,
            width: 470,
            modal: true,
            buttons: {
                "确定": function () {
                    var $this = $(this);
                    var target = $this.find('#teamTarget');
                    var id = target.find("li").attr('dataid');
                    var datavalue = target.find("li").attr('datavalue');
                    $("#RightTeamID").val(id);
                    $("#rightTeamName").val(datavalue);
                    $this.dialog("close");
                },
                "取消": function () {
                    $(this).dialog("close");
                }
            },
            close: function () {
            }
        });

        $("#leftTeamName").focus(function () {
            $("#divLeftTeam").dialog("open");
        });

        $("#rightTeamName").focus(function () {
            $("#divRightTeam").dialog("open");
        });

        $('.searchTeam').each(function () {
            var $this = $(this);
            var $containerTable = $this.parentsUntil(".teamPickerTable");
            $containerTable.find("#teamSource, #teamTarget").sortable({
                connectWith: ".connectedSortable"
            }).disableSelection();

            $this.click(function () {
                var $search = $(this);
                var ce = $search.parent().find(".condition");

                condition = $(ce).val();

                $.ajax(
                   {
                       url: "/Team/GetTeamSource",
                       datatype: "html",
                       type: 'GET',
                       data: { 'condition': condition },
                       traditional: true,
                       success: function (result) {
                           $containerTable.find("#teamSource").html(result);
                       }
                   })
            });
        });

    });
</script>
@Html.ValidationSummary(true)
<fieldset>
    <legend>赛事安排</legend>
    <div class="editor-label">
        @Html.LabelFor(model => model.StartTime)
    </div>
    <div class="editor-field">
        @Html.EditorFor(model => model.StartTime)
        @Html.ValidationMessageFor(model => model.StartTime)
    </div>
    <div class="editor-label">
        @Html.LabelFor(model => model.EndTime)
    </div>
    <div class="editor-field">
        @Html.EditorFor(model => model.EndTime)
        @Html.ValidationMessageFor(model => model.EndTime)
    </div>
    <div class="editor-label">
        @Html.LabelFor(model => model.Day)
    </div>
    <div class="editor-field">
        @Html.EditorFor(model => model.Day)
        @Html.ValidationMessageFor(model => model.Day)
    </div>
    <div class="editor-label">
        @Html.LabelFor(model => model.LeftTeamID, "队1")
    </div>
    <div class="editor-field">
        <div style="display:none">@Html.EditorFor(model => model.LeftTeamID)</div>
        @if (Model != null && Model.LeftTeam != null)
        {
             <input type="text" value="@Model.LeftTeam.FullName" id="leftTeamName" />
        }
        else
        {
            <input type="text" id="leftTeamName" />
        }
        
        <div class="divDialog" id="divLeftTeam">
            @Html.Partial(@"~\views\shared\controls\teampicker.cshtml", (Model == null || Model.LeftTeam == null) ? new Team() : Model.LeftTeam)
        </div>
        @Html.ValidationMessageFor(model => model.LeftTeamID)
    </div>
     <div class="editor-label">
        @Html.LabelFor(model => model.RightTeamID, "队2")
    </div>
    <div class="editor-field">
          <div style="display:none">@Html.EditorFor(model => model.RightTeamID)</div>
        @if (Model != null && Model.RightTeam != null)
        {
             <input type="text" value="@Model.RightTeam.FullName" id="rightTeamName" />
        }
        else
        {
            <input type="text" id="rightTeamName" />
        }
          <div class="divDialog" id="divRightTeam">
            @Html.Partial(@"~\views\shared\controls\teampicker.cshtml", (Model == null || Model.RightTeam == null) ? new Team() : Model.RightTeam)
            @Html.ValidationMessageFor(model => model.RightTeamID)
        </div>
    </div>
    <div class="editor-label">
        @Html.Label("两队比分")
    </div>
    
    <div class="editor-field">
      （队1） <span> @Html.EditorFor(model => model.LeftScore) ：@Html.EditorFor(model => model.RightScore) </span>（队2）
        @Html.ValidationMessageFor(model => model.LeftScore)
         @Html.ValidationMessageFor(model => model.RightScore)
    </div>
   
    <div class="editor-label">
        @Html.LabelFor(model => model.Field)
    </div>
    <div class="editor-field">
        @Html.EditorFor(model => model.Field)
        @Html.ValidationMessageFor(model => model.Field)
    </div>
    <div class="editor-label">
        @Html.LabelFor(model => model.Referee)
    </div>
    <div class="editor-field">
        @Html.EditorFor(model => model.Referee)
        @Html.ValidationMessageFor(model => model.Referee)
    </div>
</fieldset>
@Html.Partial(@"~\views\shared\controls\otherschange.cshtml", Model)
<p>
    <input type="submit" value="保存" />
</p>
@Html.ActionLink("回到列表", "Index")
